<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-remove"></li></button>
    <h5 class="modal-title"></h5>
</div>

<div class="modal-body">
    <form id="batch_form" name="batch_form" class="form-horizontal">
        <input type="hidden" name="id">
        <input type="hidden" name="version">
        <input type="hidden" name="createDateTime" data-flag="date" data-format="yyyy-mm-dd hh:ii:ss">
        <input type="hidden" name="deleted" value="0">
        <input type='hidden' value="${CSRFToken}" id='csrftoken'>
        <input type="hidden" id="proId" name="proId" value="${proId}">
        <div class="box-body">
            <div class="col-md-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">批次名称<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="pcName" name="pcName" placeholder="请填写批次名称">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">批次号<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="pcCode" name="pcCode" placeholder="请填写批次号">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">批次数量<span style="color:red">*</span></label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="pcNum" name="pcNum" placeholder="请填写批次数量">
                    </div>
                </div>
            </div>
        </div>
        <div class="box-footer text-right">
            <button type="button" class="btn btn-default" data-btn-type="cancel" data-dismiss="modal">取消</button>
            <button type="submit" class="btn btn-primary" data-btn-type="save">提交</button>
        </div>
    </form>
</div>
<script>
    var form;
    var id="${id?default(0)}";
    $(function(){
        //初始化表单
        form=$("#batch_form").form();
        //数据校验
        $("#batch_form").bootstrapValidator({
            message : '请输入有效值',
            feedbackIcons : {
                valid : 'glyphicon glyphicon-ok',
                invalid : 'glyphicon glyphicon-remove',
                validating : 'glyphicon glyphicon-refresh'
            },
            submitHandler : function() {
                modals.confirm('确认保存？', function() {
                    var batch = form.getFormSimpleData();
                    ajaxPost(basePath+'/batch/save',batch, function(data) {
                        if(data.success){
                            if(id!="0"){
                                modals.hideWin(batch_winId);
                                batchTable.reloadRowData(id);
                            }else{
                                modals.hideWin(batch_winId);
                                batchTable.reloadData();
                            }
                        }
                    });
                });
            },
            fields : {
                "pcName":{
                    validators:{
                        notEmpty:{message:'批次名称不能为空'}
                    }
                },
                "pcCode":{
                    validators:{
                        notEmpty:{message:'批次号不能为空'}
                    }
                },
                "pcNum":{
                    validators:{
                        notEmpty:{message:'批次数量不能为空'}
                    }
                }
            }
        });
        //初始化控件
        form.initComponent();
        //编辑回填
        if(id!=0){
            ajaxPost(basePath+"/batch/get/"+id,null,function(data){
                form.initFormData(data);
            })
        }
    });

</script>
